home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: tanmoy@qcd.Lanl.GOV (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c.moderated,comp.std.c
- Subject: Re: Integral promotion.
- Followup-To: comp.std.c
- Date: 21 Feb 1996 09:54:38 -0600
- Organization: Los Alamos National Laboratory
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4gff7u$3cg@solutions.solon.com>
- References: <4gf8q7$1bs@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
-
- In article <4gf8q7$1bs@solutions.solon.com> fred@genesis.demon.co.uk
- (Lawrence Kirby) writes:
- <snip>
- In article <4g55fl$avl@solutions.solon.com> msb@sq.com writes:
-
- > > > short test(short x1, short x2) {
- > > > short result;
- > > > result = x1 + x2;
- > >
- > > The addition operator "+" converts your short operands to ints.
- >
- > No, just using their values does that. The operator + never sees
- > operands narrower than int. In the statement
- > x1;
- > the short is converted to int before being discarded.
-
- This does however beg a question regarding the standard. Take the
- >> or << operators. In 6.3.7 we have:
-
- "Constraints
-
- Each of the operands shall have integral type
-
- Semantics
-
- The integral promotions are performed on each of the operands..."
-
- If the operator never sees operands narrower than int then this sentence
- is pointless.
-
- I initially supported the position advocated by msb@sq.com: 6.2.1.1
- states that integral promotions take place whenever an int is
- allowed. I still believe it states that, but erroneously ... after
- `char x', sizeof x better be sizeof(char) and not necessarily
- sizeof(int), even though an int is allowed as an operand of sizeof.
-
- I think the footnote needs to be brought into the body of the
- standard. I also think that either enums should be prohibited from
- being (unsigned) long, or they should be treated somewhat differently
- in this clause.
-
- In any case, currently, whether an integral promotion takes place
- before the value is discarded or not has little bearing on the
- behaviour of the program. The topic is quite okay in comp.std.c:
- there one is trying to find whether the standard is inconsistent and
- it is important to figure out how any change will interact with the
- rest of the standard. In c.l.c.m, it is probably not off-topic, but
- not very interesting. I have accordingly set follow-up to comp.std.c;
- if it survives moderator's software and it is not appropriate, please
- change it back.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-